package  ${basePackage}.${subPackage}.entity;



import java.io.*;
import java.util.*;
import javax.persistence.*;

import com.bonc.common.security.entity.*;

<?py if extend != "":?>
//此处导入本类的父类

<?py  properties = properties + models[extend]["properties"] ?>

<?py  if extend not in baseDataTypes: ?>

<?py    #print extend ?>

import ${basePackage}.${models[extend]["subPackage"]}.entity.${upperFirst(extend)};

<?py  #endif?>


<?py #endif?>

//此处导入本类引用的类
<?py for property in properties: ?>
<?py  if property["dataType"] not in baseDataTypes: ?>
<?py    datatype =  property["dataType"]?>
<?py    #print datatype ?>

import ${basePackage}.${models[datatype]["subPackage"]}.entity.${upperFirst(datatype)};

<?py  elif property["dataType"] == "List":?>
<?py    elementType =  property["elementType"]?>
import ${basePackage}.${models[elementType]["subPackage"]}.entity.${upperFirst(elementType)};


<?py  #endif?>
<?py #endfor ?>

/**
 ${comment}
*/
@Entity 
<?py if isSuper:?>
@Inheritance(strategy = InheritanceType.JOINED) 
<?py #endif?>
<?py if extend != "":?>
@PrimaryKeyJoinColumn(name = "${name.upper()}_ID") 
public class ${upperFirst(name)} extends ${upperFirst(extend)} implements Serializable
<?py else:?>
public class ${upperFirst(name)} implements Serializable
<?py #endif?>

{

  private static final long serialVersionUID = 1L;
<?py if  extend =="":?>

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    
<?py #endif?>
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (getId() != null ? getId().hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ${upperFirst(name)})) {
            return false;
        }
        ${upperFirst(name)} other = (${upperFirst(name)}) object;
        if ((this.getId() == null && other.getId() != null) || (this.getId() != null && !this.getId().equals(other.getId()))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "${upperFirst(name)}[ id=" + getId() + " ]";
    }

  
	<?py  for property in properties: ?>
	/** ${property['comment']} */
  
  <?py    if property['dataType']=='Date': ?>
    @Column
    @Temporal(javax.persistence.TemporalType.TIMESTAMP)
    private Date  ${property['name']};
   
    <?py  elif property['dataType'] not in baseDataTypes:?>
    @ManyToOne
    private ${upperFirst(property['dataType'])}  ${property['name']};
    <?py  elif property['dataType'] in ["List","Set"]:?>
    @ManyToMany(fetch=FetchType.EAGER)
    private ${upperFirst(property['dataType'])}<${upperFirst(property["elementType"])}>  ${property['name']};
    <?py  else:?>
    @Column
    private ${upperFirst(property['dataType'])}  ${property['name']};
    <?py #endif  ?>
	
	<?py  #endfor ?>

    <?py  for property in properties: ?>
     /** 
      获取${property['comment']} 
      @return ${property['dataType']} ${property['name']} 
    */
   
    <?py  	if property['dataType']=='boolean': ?>
    
    public ${upperFirst(property['dataType'])} is${upperFirst(property['name'])}()
    
    {
      return this.${property['name']};
    }

  <?py      elif property['dataType'] in ["Set","List"]: ?>

   public ${upperFirst(property['dataType'])}<${upperFirst(property['elementType'])}> get${upperFirst(property['name'])}()
    
    {
      return this.${property['name']};
    }

     /** 
      设置${property['comment']} 
      @param ${property['dataType']}<${upperFirst(property['elementType'])}> ${property['name']} 
    */
  public void set${upperFirst(property['name'])}(${property['dataType']}<${upperFirst(property['elementType'])}>  ${property['name']})
  {
        this.${property['name']} =  ${property['name']};
  }

  <?py      else:?>
 
    public ${upperFirst(property['dataType'])} get${upperFirst(property['name'])}()
    {
    return this.${property['name']};
  }
  /** 
      设置${property['comment']} 
      @param ${property['dataType']} ${property['name']} 
    */
  public void set${upperFirst(property['name'])}(${upperFirst(property['dataType'])} ${property['name']})
  {
        this.${property['name']} =  ${property['name']};
  }
    <?py    #endif	?>
	
	
	<?py  #endfor ?>
}